package entity;

import java.util.Date;
/*
* @author Omri Barda		039725890
* @author Amit Joseph		034608547
* @author Gilad Shpigel  	300162393
* @author Elad Elbaz		040539959
* @author Natali Kazav		038109401
* @version May 2012
*/


/**
 * Question construction.
 */	
public class Question {
	
		final public static int CREATE = 1;
		final public static int DELETE = 2;
		final public static int GET = 3;
		
		private	String qID;
		private	String	qText;
		private	Date	qDate;
		private	String	qCreator;
		private	String	qInstructions;
		private	String	correctAns;
		private	String	answerA;
		private	String	answerB;
		private	String	answerC;
		
		public Question()
		{}
		
		public Question(String qID, String qText, String qDate, String qCreator,String qInstructions, String correctAns, String answerA,String answerB, String answerC) 
		{			
			this.qID = qID;
			this.qText = qText;
			this.qDate = new Date(Integer.parseInt(qDate.substring(0, 3)),Integer.parseInt(qDate.substring(5, 6)),Integer.parseInt(qDate.substring(8, 9)));
			this.qCreator = qCreator;
			this.qInstructions = qInstructions;
			this.correctAns = correctAns;
			this.answerA = answerA;
			this.answerB = answerB;
			this.answerC = answerC;
		}

		public String getqID() {
			return qID;
		}

		public Boolean setqID(String qID) 
		{
			if (qID.length()!=5)
				return(false);
			this.qID = qID;
				return(true);
		}

		public String getqText() {
			return qText;
		}

		public void setqText(String qText) {
			this.qText = qText;
		}

		public Date getqDate() {
			return qDate;
		}

		public void setqDate(java.util.Date date) {
			this.qDate = date;
		}

		public String getqCreator() {
			return qCreator;
		}

		public void setqCreator(String qCreator) {
			this.qCreator = qCreator;
		}

		public String getqInstructions() {
			return qInstructions;
		}

		public void setqInstructions(String qInstructions) {
			this.qInstructions = qInstructions;
		}

		public String getCorrectAns() {
			return correctAns;
		}

		public void setCorrectAns(String correctAns) {
			this.correctAns = correctAns;
		}

		public String getAnswerA() {
			return answerA;
		}

		public void setAnswerA(String answerA) {
			this.answerA = answerA;
		}

		public String getAnswerB() {
			return answerB;
		}

		public void setAnswerB(String answerB) {
			this.answerB = answerB;
		}

		public String getAnswerC() {
			return answerC;
		}

		public void setAnswerC(String answerC) {
			this.answerC = answerC;
		}

		@Override
		/**
		 * Converting question to string.
		 */	
		public String toString() 
		{
			return "Question#:" + qID + "\n" +
					"Instructions:" + qInstructions + "\n" +
					qText + "\n" +
					"1)"  +  correctAns +
					"\n2)" + answerA +
					"\n3)" + answerB +
					"\n4)" + answerC +
					"\n";
		}
}
